//
//  drawerViewController.m
//  project-A
//
//  Created by lanou3g on 16/4/14.
//  Copyright © 2016年 孙君堂. All rights reserved.
//

#import "drawerViewController.h"
#import "CK_MenuViewController.h"
#import "LDTLoginController.h"
#import <LBXScanViewController.h>
#import "SubLBXScanViewController.h"
#import "SearchController.h"
@interface drawerViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, assign) NSInteger index;

@end

@implementation drawerViewController

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
 
  
    
    self.arr1 = [@[@"NEW 最新",@"BOYS 男生资讯",@"GIRLS 女生资讯",@"VLDEO 视频",@"FEATURE 专题",@"WALLPAPER 壁纸"]mutableCopy];
    
    self.tableView.delegate = self;
    self.tableView.dataSource  = self;
    

    
    [self.tableView reloadData];
    

    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
       // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//登录
- (IBAction)loginButton:(UIButton *)sender
{
    LDTLoginController *loginVC = [[LDTLoginController alloc]init];
    UINavigationController *navc = [[UINavigationController alloc]initWithRootViewController:loginVC];
    [self presentViewController:navc animated:YES completion:nil];
}

//搜索
- (IBAction)searchButton:(UIButton *)sender
{
    SearchController *seaVC = [[SearchController alloc]init];
    
    UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:seaVC];
    
    [self presentViewController:nav animated:YES completion:nil];
    

}

//扫描
- (IBAction)scanningButton:(UIButton *)sender
{
    SubLBXScanViewController *vc = [SubLBXScanViewController new];
   // UINavigationController *naVC = [[UINavigationController alloc]initWithRootViewController:vc];
    [self presentViewController:vc animated:YES completion:nil];
}

//下载
- (IBAction)downloadButton:(UIButton *)sender
{
     NSLog(@"下载");
}

//设置
- (IBAction)setButton:(UIButton *)sender
{
     NSLog(@"设置");
}








-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell==nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
        
    }
    if (indexPath.section==0) {
        cell.textLabel.text = self.arr1[indexPath.row];
    }else if (indexPath.section==1){
       cell.textLabel.text = self.arr2[indexPath.row];
    }
    if (indexPath.row == self.index) {
        cell.textLabel.textColor =[UIColor blackColor];
        //选中cell后有箭头
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }else{
        cell.textLabel.textColor = [UIColor grayColor];
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    cell.textLabel.backgroundColor = [UIColor clearColor];
    cell.backgroundColor = [UIColor clearColor];
    
    
    
    return cell;
}
static  drawerViewController *draw = nil;
+(instancetype)shareManager{
    
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
        draw = [[drawerViewController alloc]init];
    });
    return draw;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 取消选中状态
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    //选中变白色
    self.index = indexPath.row;
    [tableView reloadData];

    [self.drawDelegate didClickIndex:indexPath.row Section:indexPath.section];
    
    [[CK_MenuViewController getMenuViewController] hideLeftViewController];
    
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];

}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 6;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 2;
}



#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    
    
    
    
}







@end
